public class Threadingmode {

        public static void main(String[] args) {
            // Create tasks
            Runnable Hello = new Greeting(50,"你好");
            Runnable Goodbye = new Greeting(50, "再见");
            Runnable print = new student("小明","大数据",202133521);
            Runnable print1 = new student("小红","会计",202134455);
            // Create threads
            Thread thread1 = new Thread(Hello);
            Thread thread2 = new Thread(Goodbye);
            Thread thread3 = new Thread(print);
            Thread thread4 = new Thread(print1);
            // Start threads
            thread1.start();
            thread2.start();
            thread3.start();
            thread4.start();
        }
    }
    class Greeting implements Runnable {
        private String charToPrint;
        private int times;
        public Greeting(int ID,String greeting) {
            charToPrint = greeting;
            times = ID;
        }
        public void run() {
            for (int i = 0; i < times; i++) {
                System.out.print(charToPrint);
            }
        }
    }
    class student implements Runnable {
        private String name;
        private String specialized;
        private int lastNum;

        public student(String name,String specialized,int id) {
            this.name=name;
            this.specialized=specialized;
            lastNum = id;
        }
        public void run() {
            System.out.println("\n[名字："+name+" ,专业："+specialized+" ,ID："+lastNum+" ]");

        }

    }


